package com.itheima.demo.demo03.demo03ceshi;

import java.util.Arrays;
import java.util.LinkedList;

public class Test_5 {
    public static void main(String[] args) {
        LinkedList<String>linked=new LinkedList<>();
        //基本方法：add, set, get, remove, clear, size等方法；
        //（2）特有方法：addFirst, addLast, getFirst, getLast,
        // removeFirst,removeLast, push, pop, clear等方法。
        linked.add("1");
        linked.add("3");
        linked.add("2");
        linked.set(1,"4");
        String s = linked.get(2);
        System.out.println(s);
        System.out.println(linked);
        int size = linked.size();
        System.out.println("size:"+size);
        linked.addFirst("3");
        linked.addLast("5");
        String first = linked.getFirst();
        String last = linked.getLast();
        System.out.println(linked+" "+first+" "+last);
        String pop = linked.pop();
        System.out.println(pop);//相当于remove
        linked.push("2");
        System.out.println(linked);//相当于addfrist
        linked.clear();
        System.out.println(linked);



    }
}
